package com.by.utils;

import java.util.Map;

/**
 * 线程局部变量
 */
public class ThreadLocalUtils {

    static  ThreadLocalUtils instance;
    /**
     * 线程局部变量
     */
    ThreadLocal<Map> threadLocal=new ThreadLocal<>();

    /**
     * 保存数据
     * @param map
     */
    public void set(Map map){
        threadLocal.set(map);
    }

    public Map get(){
        return threadLocal.get();
    }

    public void remove(){
        threadLocal.remove();
    }
    private ThreadLocalUtils(){

    }
    public static ThreadLocalUtils getInstance(){
        if(null==instance){
            instance=new ThreadLocalUtils();
        }
        return instance;

    }
}
